﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace Example1
{
    class Program
    {
        static void Main(string[] args)
        {
            var xmlDoc = new XmlDocument();
            const string filename = @"..\..\XMLFile.xml";
            if (File.Exists(filename))
            {
                xmlDoc.Load(filename);
                Dump(xmlDoc);
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("missing XMLFile.xml");
            }
        }

        private static void Dump(XmlDocument xmlDoc)
        {
            if (xmlDoc == null) throw new ArgumentNullException("xmlDoc");
            Console.WriteLine("xmlDoc.InnerText");
            Console.WriteLine( xmlDoc.InnerText);
            Console.WriteLine("");
            Console.WriteLine("xmlDoc.InnerXml");
            Console.WriteLine(xmlDoc.InnerXml);
            Console.WriteLine("");
            Console.WriteLine("xmlDoc.DocumentElement : the root node of the document.");
            if (xmlDoc.DocumentElement != null) Console.WriteLine(xmlDoc.DocumentElement.Name);
            Console.WriteLine("");
            Console.WriteLine("xmlDoc.DocumentElement.OuterXml");
            if (xmlDoc.DocumentElement != null) Console.WriteLine(xmlDoc.DocumentElement.OuterXml);
            Console.WriteLine("");

        }
    }
}
